-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLDR-15954 Add test of unit preferences test #3571
CLDR-15954 Add test of unit preferences test #3571
Conversation
5273eca
to
85ddce1
Compare
Hooray! The files in the branch are the same across the force-push. 😃 ~ Your Friendly Jira-GitHub PR Checker Bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still reviewing
@@ -755,7 +755,11 @@ public static Set<String> getGrammarLocales() { | |||
"knot", | |||
"dalton", | |||
"kilocalorie", | |||
"electronvolt"); | |||
"electronvolt", | |||
// The following may be reinstated after 45. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need a TODO ticket link for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed yesterday: https://unicode-org.atlassian.net/browse/CLDR-17459
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good, should ideally be in code
int pos = languageTag.indexOf("-u"); | ||
String localeBase = | ||
(pos < 0 ? languageTag : languageTag.substring(0, pos)).replace('-', '_'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better not to propagate locale string slicing
int pos = languageTag.indexOf("-u"); | |
String localeBase = | |
(pos < 0 ? languageTag : languageTag.substring(0, pos)).replace('-', '_'); | |
final String localeBase = ULocale.forLanguageTag(languageTag).getBaseName(); |
something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm planning on another PR anyway, and will look at this. Since the beta is already tagged, would you mind approving now if there are no substantive issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rubber-stamp approval; added suggestions for improvement
@@ -2,7 +2,7 @@ | |||
# Test data for unit preferences |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment, "DO NOT EDIT THIS FILE, it is autogenerated by GenerateUnitTestData.java"?
@@ -1,7 +1,7 @@ | |||
# Test data for unit conversions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment, "DO NOT EDIT THIS FILE, it is autogenerated by GenerateUnitTestData.java"?
// This includes the header, so modify the old header if changes are needed! | ||
Files.lines(Path.of(CLDRPaths.TEST_DATA + "units/unitLocalePreferencesTest.txt")) | ||
.forEach(line -> formatPwLocale(pwLocale, line, seen)); | ||
// TODO: add more lines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO comment should have a ticket link, ticket shouldn't be closed until comment is removed
String expectedQuantity = converter.getQuantityFromUnit(inputUnit, false); | ||
assertEquals("Input: Quantity consistency check", expectedQuantity, quantity); | ||
|
||
// TODO handle mixed_unit_identifiers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO should have ticket number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to do that in a subsequent PR. I had to squash, and it is much simpler to do in a follow-on PR.
String expectedQuantity = converter.getQuantityFromUnit(sourceUnit, false); | ||
assertEquals("Input: Quantity consistency check", expectedQuantity, quantity); | ||
|
||
// TODO check conversion equation (not particularly important |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO should have ticket and closing parenthesis
I will, however, be waiting until I get the go-ahead from Dragan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK for now, comments noted
@@ -755,7 +755,11 @@ public static Set<String> getGrammarLocales() { | |||
"knot", | |||
"dalton", | |||
"kilocalorie", | |||
"electronvolt"); | |||
"electronvolt", | |||
// The following may be reinstated after 45. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good, should ideally be in code
switch (ms) { | ||
case "metric": | ||
return "001"; | ||
case "uksystem": | ||
return "GB"; | ||
case "ussystem": | ||
return "US"; | ||
default: | ||
throw new IllegalArgumentException( | ||
"Illegal ms value in: " + locale.toLanguageTag()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be data driven.. or actually lookup prefernces
throw new IllegalArgumentException("Fast map should always terminate"); | ||
} | ||
|
||
public String resolveRegion(ULocale locale) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function should move into supplemental data info
CLDR-15954
The main goal was to add tests of test files, for verification. It grew a bit as I discovered and fixed problems.
common/testData/units/unitLocalePreferencesTest.txt
common/testData/units/unitPreferencesTest.txt
common/testData/units/unitsTest.txt
tools/cldr-code/src/main/java/org/unicode/cldr/tool/GenerateUnitTestData.java
tools/cldr-code/src/main/java/org/unicode/cldr/util/GrammarInfo.java
tools/cldr-code/src/main/java/org/unicode/cldr/util/Rational.java
tools/cldr-code/src/main/java/org/unicode/cldr/util/UnitConverter.java
tools/cldr-code/src/main/java/org/unicode/cldr/util/UnitPreferences.java
tools/cldr-code/src/main/java/org/unicode/cldr/util/Units.java
tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestUnits.java
Added Rational tests for NaN, INF
Added testQuantitiesMissingFromPreferences(), to identify when quantities we don't have in preferences
Added test of the unitPreferencesTest.txt, unitsTest.txt, and (new) unitLocalePreferencesTest.txt data files
Also added a testUnitLocalePreferencesTestIcu() so that we could see how ICU was doing without waiting for integration (it is under a flag, so not normally run).
This PR completes the ticket.
ALLOW_MANY_COMMITS=true